#include "sysinfo.h"
#include "include.h"

sysinfo::sysinfo()
{
   char* tmp=new char[MAXPATHSIZE];
   size_t size=MAXPATHSIZE;
   uv_exepath (tmp,&(size));
   this->selfPath=std::string(tmp);
   delete[] tmp;
   tmp=new char[MAXPATHSIZE];
   getcwd (tmp,MAXPATHSIZE);
   this->workDir=std::string(tmp);

   this->cpuInfo=new uv_cpu_info_t;
   uv_cpu_info (&(this->cpuInfo),&(this->cpuCount));
}

sysinfo::~sysinfo (){
    uv_free_cpu_info (this->cpuInfo,cpuCount);
}

auto sysinfo::getCpuCount (){
    return this->cpuCount;
}

auto sysinfo::getSelfPath (){
    return this->selfPath;
}

auto sysinfo::getWorkDir (){
    return this->workDir;
}

auto sysinfo::updateWorkDir (){
    char* tmp=new char[MAXPATHSIZE];
    getcwd(tmp,MAXPATHSIZE);
    this->workDir=std::string(tmp);
}
